package com.leenleda.ips.util;

public class CardYanShan {

    private static String tag = "CardYanShan";

    public static String formatCardStr(String data) {

        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-55----==" + data);
        String str1 = data.substring(0,2);
        String str2 = data.substring(2,4);
        String str3 = data.substring(4,6);
        String str4 = data.substring(6,8);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-61----==" + str1);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-62----==" + str2);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-63----==" + str3);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-64----==" + str4);
        String str5 = data.substring(8,10);
        String str6 = data.substring(10,12);
        String str7 = data.substring(12,14);
        String str8 = data.substring(14,16);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-65----==" + str5);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-66----==" + str6);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-67----==" + str7);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-68----==" + str8);
        String strAll = "80" + getFormatStr(str1)
                + getFormatStr(str2)
                + getFormatStr(str3)
                + getFormatStr(str4)
                + getFormatStr(str5)
                + getFormatStr(str6)
                + getFormatStr(str7)
                + getFormatStr(str8);
        LogUtils.e(tag, "==jsonObject-----sReadBlockRet-strAll----==" + strAll);
        return strAll;
    }

    private static String getFormatStr(String str){

        switch (str){
            case "48":
            case "4B":
            case "5C":
            case "6B":
            case "6E":
            case "75":
            case "85":
            case "88":
            case "C8":
            case "CB":
                //48，4B，5C，6B，6E，75，85，88，C8，CB
                return "1";
            case "11":
            case "5D":
            case "6F":
            case "95":
            case "A2":
            case "DD":
            case "DF":
            case "ED":
            case "F2":
            case "F3":
                //11，5D，6F，95，A2，DD，DF，ED，F2，F3
                return "2";
            case "0E":
            case "1C":
            case "22":
            case "38":
            case "49":
            case "8C":
            case "A5":
            case "B7":
            case "CF":
            case "FE":
                //0E，1C，22，38，49，8C，A5，B7，CF，FE
                return "3";
            case "00":
            case "06":
            case "2C":
            case "3A":
            case "52":
            case "58":
            case "5E":
            case "9B":
            case "C1":
            case "EE":
                //00，06，2C，3A，52，58，5E，9B，C1，EE
                return "4";
            case "1A":
            case "1F":
            case "5F":
            case "99":
            case "9C":
            case "B4":
            case "D3":
            case "D7":
            case "E0":
            case "FB":
                //1A，1F，5F，99，9C，B4，D3，D7，E0，FB
                return "5";
            case "0B":
            case "19":
            case "2A":
            case "33":
            case "3C":
            case "67":
            case "8E":
            case "C3":
            case "E1":
            case "FC":
                //0B，19，2A，33，3C，67，8E，C3，E1，FC
                return "6";
            case "15":
            case "43":
            case "50":
            case "53":
            case "5B":
            case "61":
            case "79":
            case "97":
            case "B8":
            case "D5":
                // 15，43，50，53，5B，61，79，97，B8，D5
                return "7";
            case "1B":
            case "24":
            case "27":
            case "2D":
            case "71":
            case "A7":
            case "AE":
            case "C2":
            case "DC":
            case "F0":
                //1B，24，27，2D，71，A7，AE，C2，DC，F0
                return "8";
            case "54":
            case "7C":
            case "8D":
            case "92":
            case "C6":
            case "D6":
            case "DA":
            case "F4":
            case "FD":
            case "FF":
                //54，7C，8D，92，C6，D6，DA，F4，FD，FF
                return "9";
            case "08":
            case "0F":
            case "13":
            case "34":
            case "39":
            case "45":
            case "4E":
            case "4F":
            case "57":
            case "59":
            case "62":
            case "63":
            case "72":
            case "73":
            case "74":
            case "7E":
            case "82":
            case "8A":
            case "8B":
            case "8F":
            case "93":
            case "96":
            case "A8":
            case "AD":
            case "B0":
            case "B1":
            case "B6":
            case "BC":
            case "BD":
            case "BF":
            case "C4":
            case "C7":
            case "D4":
            case "D8":
            case "D9":
            case "E4":
            case "E5":
            case "E9":
            case "F5":
            case "F9":
                return "0";
        }
        return "";
    }
}
